package com.javaeye.chenweihuacwh.dao.baseData;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.javaeye.chenweihuacwh.dto.baseData.ProductCategory;

public class ProductCategoryDAOHibernate extends HibernateDaoSupport  implements ProductCategoryDAO {

	@Override
	public ProductCategory getCategory(int id) {
		return (ProductCategory)getHibernateTemplate().get(ProductCategory.class, id);
	}

	@Override
	public List getCategorys() {
		return getHibernateTemplate().find("from ProductCategory");
	}

	@Override
	public void removeCategory(int id) {
		Object o = getHibernateTemplate().get(ProductCategory.class, id);
		getHibernateTemplate().delete(o);
	}

	@Override
	public void saveCategory(ProductCategory category) {
		getHibernateTemplate().saveOrUpdate(category);
		logger.debug("ProductCategory id set to: " + category.getId());
	}
}
